Ccay.Module.define("ccay.security.program.edit",function (page,$S) {
	
	page.init = function(programId) {
		$S("#programId").val(programId);
		Program.renderItems("programItemId","edit",programId,"programName","description");
	}
	
	$.validator.addMethod("checkProgramNameUnique", function(value, element, param) {
		var result = true;
		param = {programName:value};
		var programId = $S("#programId").val();
		if(programId){
			param.programId = programId;
		}
		Ccay.doGet({
 			async:false,
 			url:"services/manage/security/programManage/checkProgramNameUnique",
 			data :param,
 			success:function(data){
 				result = data;
 			}			
 		});
 		return result;
	}, "数据范围名称已存在");
	
	//保存数据
	page.submit=function () {
		if(!$S("#editProgramForm").valid())return ;
		var saveObject=$S("#editProgramForm").jsonData();
		var programVO={
			programId : saveObject.programId,
			programName : saveObject.programName,
			description : saveObject.description,
			dimensions : Program.getDimensionJson("programItemId")
		};
		Ccay.doPost({
 			async:true,
 			url:"services/manage/security/programManage/createOrUpdateProgram",
 			data : programVO,
 			success:function(result){
 				Ccay.UI.topBox($i18n('ccay.common.message.success'));
 				ccay.security.role.list.closeTab(true);
 			}			
 		});
	};


});
